package com.columboid.protocol.syncml.devicemgmt;

import java.util.ArrayList;
import java.util.List;

/**
 * Schema fragment(s) for this class:
 * 
 * <pre>
 * &lt;xs:element xmlns:ns=&quot;http://protocol.columboid.com/syncml/devicemgmt&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; name=&quot;Node&quot;&gt;
 *   &lt;xs:complexType&gt;
 *     &lt;xs:sequence&gt;
 *       &lt;xs:element ref=&quot;ns:NodeName&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:Path&quot; minOccurs=&quot;0&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:RTProperties&quot; minOccurs=&quot;0&quot;/&gt;
 *       &lt;xs:element ref=&quot;ns:DFProperties&quot;/&gt;
 *       &lt;xs:choice&gt;
 *         &lt;xs:element ref=&quot;ns:Node&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;/&gt;
 *         &lt;xs:element ref=&quot;ns:Value&quot; minOccurs=&quot;0&quot;/&gt;
 *       &lt;/xs:choice&gt;
 *     &lt;/xs:sequence&gt;
 *   &lt;/xs:complexType&gt;
 * &lt;/xs:element&gt;
 * </pre>
 */
public class Node {
	private NodeName nodeName;
	private Path path;
	private RTProperties RTProperties;
	private DFProperties DFProperties;
	private int choiceSelect = -1;
	private static final int NODE_CHOICE = 0;
	private static final int VALUE_CHOICE = 1;
	private List<Node> nodeList = new ArrayList<Node>();
	private Value value;

	/**
	 * Get the 'NodeName' element value.
	 * 
	 * @return value
	 */
	public NodeName getNodeName() {
		return nodeName;
	}

	/**
	 * Set the 'NodeName' element value.
	 * 
	 * @param nodeName
	 */
	public void setNodeName(NodeName nodeName) {
		this.nodeName = nodeName;
	}

	/**
	 * Get the 'Path' element value.
	 * 
	 * @return value
	 */
	public Path getPath() {
		return path;
	}

	/**
	 * Set the 'Path' element value.
	 * 
	 * @param path
	 */
	public void setPath(Path path) {
		this.path = path;
	}

	/**
	 * Get the 'RTProperties' element value.
	 * 
	 * @return value
	 */
	public RTProperties getRTProperties() {
		return RTProperties;
	}

	/**
	 * Set the 'RTProperties' element value.
	 * 
	 * @param RTProperties
	 */
	public void setRTProperties(RTProperties RTProperties) {
		this.RTProperties = RTProperties;
	}

	/**
	 * Get the 'DFProperties' element value.
	 * 
	 * @return value
	 */
	public DFProperties getDFProperties() {
		return DFProperties;
	}

	/**
	 * Set the 'DFProperties' element value.
	 * 
	 * @param DFProperties
	 */
	public void setDFProperties(DFProperties DFProperties) {
		this.DFProperties = DFProperties;
	}

	private void setChoiceSelect(int choice) {
		if (choiceSelect == -1) {
			choiceSelect = choice;
		} else if (choiceSelect != choice) {
			throw new IllegalStateException(
					"Need to call clearChoiceSelect() before changing existing choice");
		}
	}

	/**
	 * Clear the choice selection.
	 */
	public void clearChoiceSelect() {
		choiceSelect = -1;
	}

	/**
	 * Check if Nodes is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifNode() {
		return choiceSelect == NODE_CHOICE;
	}

	/**
	 * Get the list of 'Node' element items.
	 * 
	 * @return list
	 */
	public List<Node> getNodes() {
		return nodeList;
	}

	/**
	 * Set the list of 'Node' element items.
	 * 
	 * @param list
	 */
	public void setNodes(List<Node> list) {
		setChoiceSelect(NODE_CHOICE);
		nodeList = list;
	}

	/**
	 * Check if Value is current selection for choice.
	 * 
	 * @return <code>true</code> if selection, <code>false</code> if not
	 */
	public boolean ifValue() {
		return choiceSelect == VALUE_CHOICE;
	}

	/**
	 * Get the 'Value' element value.
	 * 
	 * @return value
	 */
	public Value getValue() {
		return value;
	}

	/**
	 * Set the 'Value' element value.
	 * 
	 * @param value
	 */
	public void setValue(Value value) {
		setChoiceSelect(VALUE_CHOICE);
		this.value = value;
	}
}
